<?php
class Controller_Admin_Scenictype extends Controller_Form
{
    public function __construct ($req, $res)
  {
        $this->_list_pagesize = 20;
        $this->_form_type  = 'scenictype';

        parent::__construct($req, $res);
        $this->_list_where = array();
  }
    
    public function action_index ()
  {     $this->action_list();  }

    
    public function action_create ()
  {
        $post = $this->request->post();
        if (! empty($post))
        {
        $this->rebuild_post_data($post);
        $this->_form_data = $post;
        }        
        parent::action_create();
  }
    
    public function action_update ($nid=null)   
  {
       $post = $this->request->post();
       if (! empty($post))
       {
       $this->rebuild_post_data($post);
       $this->_form_data = $post;
       }
       else
       {
       $data = Form_Data::detail($this->_form_type, $nid); 
       $this->_form_data = $data;
       }

       parent::action_update($nid);
   }

    public function action_detail ($nid)
   {
       $data = Form_Data::detail($this->_form_type, $nid);
       $this->_form_data = $data;
       parent::action_detail($nid);
   }

    private function rebuild_post_data (& $post)
   { 
   	
   }                                                                                                                                                                                                        
    public function list_get_data ($offset, $limit)
   {
   	
   }
    
    public function list_filter_data (& $rows)
   {
       foreach ($rows as & $rs)
      {
        $city=App_City::getNameCnById($rs['cityId'], 'cityName');
        $country=App_City::getNameCnById($rs['cityId'], 'countryName');
        $rs['cityId']=$country.'|'.$city;
      }
   }
    public function classname_by_list_row (& $row)
   {
   	
   }
     
    public function actions_by_list_row (& $row, & $menus)
   {     
       unset($menus[0]);
   }
   
    public function action_delete ($nid)
   {
	   if(!empty($nid)){
   	      DB::delete('mod_scenic_type')->where('id','=',$nid)->execute();
	   }
   }

}



